| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import OS from '../client/OS' |
||
| 3 | |||
| 4 | abstract class Tool { |
||
| 5 | |||
| 6 | abstract name: string |
||
| 7 | abstract alias: string |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Install the app. |
||
| 11 | */ |
||
| 12 | install = async (): Promise<boolean> => { |
||
| 13 | if (await this.isInstalled()) { |
||
| 14 | error(`${this.name} already is installed.`) |
||
| 15 | return false |
||
| 16 | } |
||
| 17 | |||
| 18 | info(`Installing ${this.name}...`) |
||
| 19 | await OS.getInstance().packageManager.install(this.alias, false) |
||
| 20 | return true |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Uninstall the app. |
||
| 25 | */ |
||
| 26 | uninstall = async (): Promise<boolean> => { |
||
| 27 | if (!(await this.isInstalled())) { |
||
| 28 | error(`${this.name} is not installed.`) |
||
| 29 | return false |
||
| 30 | } |
||
| 31 | |||
| 32 | info(`Uninstalling ${this.name}...`) |
||
| 33 | |||
| 34 | await OS.getInstance().packageManager.uninstall(this.alias, false) |
||
| 35 | |||
| 36 | success(`Uninstalled ${this.name}.`) |
||
| 37 | |||
| 38 | return true |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Check if app the is already installed.. |
||
| 43 | */ |
||
| 44 | isInstalled = async (): Promise<boolean> => { |
||
| 45 | return OS.getInstance().packageManager.packageIsInstalled(this.alias) |
||
| 46 | } |
||
| 51 |